import matplotlib.pyplot as plt
import numpy as np


def init_figs(nrows=1, ncolumns=1, transpose=False, row_width=6.4, column_height=4.8, add_label=True, label='a',
              base_size=16, axis_size=14, **fig_kw):

    font_options = {'family': 'Arial',
                    'weight': 'regular',
                    'size': base_size}
    plt.rc('font', **font_options)

    fig, axs = plt.subplots(nrows, ncolumns, figsize=(ncolumns * row_width, nrows * column_height), **fig_kw)
    if add_label:
        if type(axs) is np.ndarray:                    # 单图不加 a) b)
            if transpose:                              # 多图加 a) b)
                for i, ax in enumerate(axs.T.flatten()):
                    ax.text(-0.05, 1.05, chr(ord(label) + i) + ')',
                            ha='right', va='center', transform=ax.transAxes, size=axis_size)
            else:
                for i, ax in enumerate(axs.flatten()):
                    ax.text(-0.05, 1.05, chr(ord(label) + i) + ')',
                            ha='right', va='center', transform=ax.transAxes, size=axis_size)

    return fig, axs
